<%--
功能：获取指定内容目录下的子目录
--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ tag import="java.util.List" %>
<%@ tag import="org.springframework.context.ApplicationContext" %>
<%@ tag import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ tag import="com.probiz.estore.catalog.service.ContentCategoryManager" %>
<%@ tag import="com.probiz.estore.common.model.catalog.ContentCategory" %>
<%@ tag import="com.probiz.estore.catalog.model.BaseCategory" %>
<%@ tag import="com.probiz.estore.catalog.model.BaseCategorySearchCriteria" %>

<%@ attribute name="categoryId" type="java.lang.Integer" required="false" description="父目录id" %>
<%@ attribute name="categoryCode" type="java.lang.String" required="false" description="父目录categoryCode.如果categoryId无指定，则必须制定categoryCode" %>
<%@ attribute name="depth" type="java.lang.Integer" required="true" description="获取的深度" %>

<%@ attribute name="returnRootCategoryName" type="java.lang.String" required="true" description="要返回的根Category的名称" %>

<%
	ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
	ContentCategoryManager contentCategoryManager = (ContentCategoryManager) ctx.getBean("contentCategoryManager");
	BaseCategorySearchCriteria categorySearchCriteria = new BaseCategorySearchCriteria();
	categorySearchCriteria.setStatuses(new String[]{"1"});
	Integer parentCategoryId = categoryId;
	if(null == parentCategoryId){
		ContentCategory contentParentCategory = contentCategoryManager.getCategoryByCode(categoryCode);
		if(contentParentCategory == null)return;
		parentCategoryId = contentParentCategory.getCategoryId();
	}
	BaseCategory parentCategory = contentCategoryManager.getCategoryById(parentCategoryId);
	parentCategory = contentCategoryManager.getCategoryTree(parentCategory, depth,categorySearchCriteria);	
	request.setAttribute(returnRootCategoryName,parentCategory);
%>
<jsp:doBody />
